<?xml version="1.0" encoding="utf-8"?>
<ROOT>
  <CLUSTER>
    <PARAM name="clusterName" value="{{ combined_vars.openGauss_env.clusterName }}" />
    <PARAM name="nodeNames" value="{{ og_host_list }}"/>
    <PARAM name="gaussdbAppPath" value="{{ combined_vars.openGauss_paths.gaussdbAppPath }}" />
    <PARAM name="gaussdbLogPath" value="{{ combined_vars.openGauss_paths.gaussdbLogPath }}" />
    <PARAM name="tmpMppdbPath" value="{{ combined_vars.openGauss_paths.tmpMppdbPath }}"/>
    <PARAM name="gaussdbToolPath" value="{{ combined_vars.openGauss_paths.gaussdbToolPath }}" />
    <PARAM name="corePath" value="{{ combined_vars.openGauss_paths.corePath }}"/>
    <PARAM name="backIp1s" value="{{ og_ip_list }}"/>
  </CLUSTER>
  
  <DEVICELIST>
{% for node in (groups['openGauss'] | sort) %}

    <DEVICE sn="opengauss{{ loop.index }}">
      <PARAM name="name" value="opengauss{{ loop.index }}"/>
      <PARAM name="azName" value="{{ combined_vars.openGauss_env.azName | default('AZ1') }}"/>
      <PARAM name="azPriority" value="{{ hostvars[node]['azPriority'] | default('1') }}"/>
      <PARAM name="backIp1" value="{{ hostvars[node]['backIp1'] | default(hostvars[node]['inventory_hostname']) }}"/>
      <PARAM name="sshIp1" value="{{ hostvars[node]['inventory_hostname'] }}"/>
{% if node in groups['openGauss_master'] %}
  {% if (groups['openGauss'] | count) > 2 %}
  
      <!-- CLUSTER MANAGER --> 
      <PARAM name="cmsNum" value="1"/> 
      <PARAM name="cmServerPortBase" value="{{ combined_vars.openGauss_env.cmServerPortBase }}"/> 
      <PARAM name="cmServerListenIp1" value="{{ og_ip_list }}"/> 
      <PARAM name="cmServerHaIp1" value="{{ og_ip_list }}"/> 
      <PARAM name="cmServerlevel" value="1"/> 
      <PARAM name="cmServerRelation" value="{{ og_host_list }}"/> 
      <PARAM name="cmDir" value="{{ og_data_path }}/cmserver"/> 
  {% endif %}

      <!-- Data Node -->
      <PARAM name="dataNum" value="1"/>
      <PARAM name="dataPortBase" value="15400"/>
      <PARAM name="dataNode1" value="{{ og_data_path }}/dn
      {%- for dn_node in (groups['openGauss'] | sort) if dn_node != inventory_hostname -%}      
        ,opengauss{{ loop.index + 1 }},{{ og_data_path }}/dn
      {%- endfor -%}
      "/>
      <PARAM name="dataNode1_syncNum" value="0"/>
{% endif %}
{% if node not in groups['openGauss_master'] 
  and (groups['openGauss'] | count) > 2 %}

      <!-- CLUSTER MANAGER --> 
      <PARAM name="cmServerPortStandby" value="{{ combined_vars.openGauss_env.cmServerPortBase }}"/> 
      <PARAM name="cmDir" value="{{ og_data_path }}/cmserver"/>
  {% if node in groups['openGauss_cascade'] %}

      <PARAM name="cascadeRole" value="on"/>
  {% endif %}
{% endif %}
    </DEVICE>
{% endfor %}

  </DEVICELIST>
</ROOT>
